<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('orders', function (Blueprint $table) {
            $table->id();
            $table->string('order_no')->comment('内部单号');
            $table->bigInteger('user_id')->default(0)->comment('员工ID,线上订单员工为0');
            $table->bigInteger('member_id')->nullable()->comment('会员ID');
            $table->bigInteger('store_id')->comment('店铺ID');
            $table->string('status')->default(\App\Enums\TradeStatus::Created->value)->comment('订单状态');
            $table->decimal('money')->comment('实际金额');
            $table->decimal('discount_money')->default(0)->comment('优惠金额');
            $table->decimal('origin_money')->comment('原价');
            $table->string('pay_channel')->nullable()->comment('支付渠道');
            $table->boolean('handover')->default(false)->comment('是否已交接');
            $table->string('comment')->nullable()->comment('备注');
            $table->string('type')->default(\App\Enums\OrderType::Counter)->comment('订单类型');
            $table->string('from')->comment('订单来源');
            $table->dateTime('pay_at')->nullable()->comment('支付时间');
            $table->timestamps();
            $table->softDeletes();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('orders');
    }
};
